-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
replace opencv-python
with scikit-image
for snowball detection
#138
base: main
Are you sure you want to change the base?
replace opencv-python
with scikit-image
for snowball detection
#138
Conversation
Contour-finding also needs to be ported from
def find_circles(dqplane, bitmask, min_area):
# Using an input DQ plane this routine will find the groups of pixels with at least the minimum
# area and return a list of the minimum enclosing circle parameters.
pixels = np.bitwise_and(dqplane, bitmask)
if ELLIPSE_PACKAGE == 'opencv-python':
contours, hierarchy = cv.findContours(pixels, cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
bigcontours = [con for con in contours if cv.contourArea(con) >= min_area]
circles = [cv.minEnclosingCircle(con) for con in bigcontours]
else:
# raise ModuleNotFoundError(ELLIPSE_PACKAGE_WARNING)
raise ModuleNotFoundError('`opencv-python` required for this functionality') |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #138 +/- ##
==========================================
+ Coverage 84.74% 85.35% +0.61%
==========================================
Files 44 46 +2
Lines 8527 8693 +166
==========================================
+ Hits 7226 7420 +194
+ Misses 1301 1273 -28 ☔ View full report in Codecov by Sentry. |
As described in #126 (comment), there are some differences in the methods used to construct ellipses between the two packages which result in different image masks. Perhaps a warning should make this more clear.
|
349d600
to
ca9758c
Compare
b73fd2d
to
0c3d1ad
Compare
expanding the ellipse test case to a more oblong shape reveals a few edge cases in the |
e7e7235
to
8793d4a
Compare
tests/test_jump.py
Outdated
@@ -40,23 +45,25 @@ def test_find_simple_circle(): | |||
plane[2, 3] = DQFLAGS['JUMP_DET'] | |||
plane[2, 1] = DQFLAGS['JUMP_DET'] | |||
circle = find_circles(plane, DQFLAGS['JUMP_DET'], 1) | |||
assert circle[0][0] == pytest.approx((2, 2)) | |||
assert circle[0][1] == pytest.approx(1.0, 1e-3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here is where the fit circle from the scikit-image
contour differs from the opencv-python
circle; the radius is 1.5 instead of 1
Currently, the |
we should also get input from INS on whether this alternative is acceptable |
f5b745e
to
6775cf3
Compare
6775cf3
to
bbc4608
Compare
started regression test run against this branch at https://plwishmaster.stsci.edu:8081/blue/organizations/jenkins/RT%2FJWST/detail/JWST/2925/pipeline |
Thanks for testing! Where is |
oh I can search that on MAST! Nevermind I'll use that, thanks anyway! 😅 |
2935dcd
to
9a7727b
Compare
ccb4c26
to
4905e09
Compare
4905e09
to
ee836ed
Compare
f7834fb
to
4cd5ef4
Compare
a1f05b1
to
2d9a2c0
Compare
c671cc3
to
1fa5161
Compare
1fa5161
to
d279a98
Compare
Closes spacetelescope/jwst#7409
This PR
adds fallback functions forreplaces ellipse construction usingscikit-image
and, removingshapely
opencv-python
entirely. Thescikit-image
+methods produce slightly different contours, ellipses, and circles thanshapely
opencv-python
.Checklist
CHANGES.rst
(either inBug Fixes
orChanges to API
)